<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-07-17 11:00
 *
 * Version: 2.0
 */

namespace App\Modules\Employee\Repositories;


use App\Models\UserPortfolioLike;
use App\Modules\Employee\Criterias\getNewPortfolioListCriteria;
use App\Modules\Employee\Validators\UserPortfolioLikeValidator;
use Flower\Core\Repository\Eloquent\BaseRepository;

class PortfolioLikeRepository extends BaseRepository
{
	public function model()
	{
		return UserPortfolioLike::class;
	}
	public function validator()
	{
		return UserPortfolioLikeValidator::class;
	}

	/**
	 * 作品集点赞
	 * @param $memberId
	 * @param $portfolioId
	 * @return mixed
	 */
	public function addLikePortfolio($memberId,$portfolioId){
		return $this->create([
			'member_id' => $memberId,
			'portfolio_id'=>$portfolioId
		]);
	}

	/**
	 * 删除作品集
	 * @param $memberId
	 * @param $portfolioId
	 * @return int
	 */
	public function deletePortfolio($memberId,$portfolioId){
		return $this->deleteWhere([
			'member_id' => $memberId,
			'portfolio_id'=>$portfolioId
		]);
	}

	/**
	 * 用户是否点赞
	 * @param $memberId
	 * @param $portfolioId
	 * @return int
	 */
	public function isLike($memberId,$portfolioId){
		$isLike = $this->model->where(['member_id'=>$memberId,'portfolio_id'=>$portfolioId])->first();
		return isset($isLike) ? 1 : 0;
	}

}